package com.itlong.cloud.property.resource;

import com.itlong.cloud.POJO.DTO.BaseDTO;
import com.itlong.cloud.POJO.DTO.operate.OperateWeChatDTO;
import com.itlong.cloud.POJO.DTO.property.PropertyWeChatDTO;
import com.itlong.cloud.POJO.PO.WeChatOfficialAuthInfoPO;
import com.itlong.cloud.POJO.VO.operate.OperateWeChatVO;
import com.itlong.cloud.POJO.VO.property.PropertyWeChatVO;
import com.itlong.cloud.property.service.IPropertyWeChatService;
import com.itlong.cloud.user.property.IPropertyWeChatServiceClient;
import com.itlong.cloud.utils.page.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * <desc>
 *      物业-微信支付相关暴露接口实现类
 * </desc>
 *
 * @createDate 2019/09/09
 */
@RestController
public class PropertyWeChatServiceResource implements IPropertyWeChatServiceClient {

    @Autowired
    private IPropertyWeChatService iPropertyWeChatService;

    /**
     * <desc>
     *      获取用户授权的appId
     * </desc>
     *
     * @return 用户授权的appId
     * @author wangzhi
     * @createDate 2019/09/09
     */
    @Override
    @PostMapping(path = "property/weChat/getAppId")
    public List<Map<String, Object>> getAppId(@RequestBody BaseDTO baseDTO) throws Exception {
        return iPropertyWeChatService.getAppId(baseDTO);
    }

    /**
     * <desc>
     *      添加appId对应商户号
     * </desc>
     *
     * @return 受影响行数
     * @author wangzhi
     * @createDate 2019/09/10
     */
    @Override
    @PostMapping(path = "property/weChat/saveMchId")
    public Integer saveMchId(@RequestBody PropertyWeChatDTO propertyWeChatDTO) throws Exception {
        return iPropertyWeChatService.saveMchId(propertyWeChatDTO);
    }

    /**
     * <desc>
     *      分页查询appId和商户号信息
     * </desc>
     *
     * @return 分页数据信息
     * @author wangzhi
     * @createDate 2019/09/10
     */
    @Override
    @PostMapping(path = "property/weChat/getMchIdPage")
    public Page<PropertyWeChatVO> getMchIdPage(@RequestBody PropertyWeChatDTO propertyWeChatDTO) throws Exception {
        return iPropertyWeChatService.getMchIdPage(propertyWeChatDTO);
    }

    /**
     * <desc>
     *      保存微信公众号授权信息
     * </desc>
     *
     * @return 受影响行数
     * @author wangzhi
     * @createDate 2019/09/10
     */
    @Override
    @PostMapping(path = "property/weChat/saveWeChatAuthInfoCallBack")
    public Integer saveWeChatAuthInfoCallBack(@RequestBody WeChatOfficialAuthInfoPO weChatOfficialAuthInfoPO) throws Exception {
        return iPropertyWeChatService.saveWeChatAuthInfoCallBack(weChatOfficialAuthInfoPO);
    }

    /**
     * <desc>
     *      获取公众号列表
     * </desc>
     *
     * @return 公众号列表
     * @author wangzhi
     * @createDate 2019/10/21
     */
    @Override
    @PostMapping(path = "property/weChat/getAppIdPage")
    public Page<PropertyWeChatVO> getAppIdPage(@RequestBody BaseDTO baseDTO) throws Exception {
        return iPropertyWeChatService.getAppIdPage(baseDTO);
    }

    /**
     * <desc>
     *      查看用户授权
     * </desc>
     *
     * @return 用户授权信息
     * @author wangzhi
     * @createDate 2019/10/21
     */
    @Override
    @PostMapping(path = "property/weChat/getOneAppId")
    public PropertyWeChatVO getOneAppId(@RequestBody PropertyWeChatDTO propertyWeChatDTO) throws Exception {
        return iPropertyWeChatService.getOneAppId(propertyWeChatDTO);
    }

    /**
     * <desc>
     *      解除微信公众号绑定
     * </desc>
     *
     * @return 受影响行数
     * @author wangzhi
     * @createDate 2019/10/21
     */
    @Override
    @PostMapping(path = "property/weChat/deleteAppIdBinding")
    public Integer deleteAppIdBinding(@RequestBody PropertyWeChatDTO propertyWeChatDTO) throws Exception {
        return iPropertyWeChatService.deleteAppIdBinding(propertyWeChatDTO);
    }

    /**
     * <desc>
     *      修改appId对应商户号
     * </desc>
     *
     * @return 受影响行数
     * @author wangzhi
     * @createDate 2019/10/22
     */
    @Override
    @PostMapping(path = "property/weChat/updateMchId")
    public Integer updateMchId(@RequestBody PropertyWeChatDTO propertyWeChatDTO) throws Exception {
        return iPropertyWeChatService.updateMchId(propertyWeChatDTO);
    }

    /**
     * <desc>
     *      解除商户号绑定
     * </desc>
     *
     * @return 受影响行数
     * @author wangzhi
     * @createDate 2019/10/22
     */
    @Override
    @PostMapping(path = "property/weChat/deleteMchIdBinding")
    public Integer deleteMchIdBinding(@RequestBody PropertyWeChatDTO propertyWeChatDTO) throws Exception {
        return iPropertyWeChatService.deleteMchIdBinding(propertyWeChatDTO);
    }

    /**
     * <desc>
     *      查询开通微信支付的所有项目及详细信息
     * </desc>
     *
     * @return 开通微信支付的所有项目及详细信息
     * @author wangzhi
     * @createDate 2019/10/23
     */
    @Override
    @PostMapping(path = "operate/weChat/getWeChatPayPage")
    public Page<OperateWeChatVO> getWeChatPayPage(@RequestBody OperateWeChatDTO operateWeChatDTO) throws Exception {
        return iPropertyWeChatService.getWeChatPayPage(operateWeChatDTO);
    }

    /**
     * <desc>
     *      添加公众号AppSecret
     * </desc>
     *
     * @return 受影响行数
     * @author wangzhi
     * @createDate 2019/11/05
     */
    @Override
    @PostMapping(path = "operate/weChat/saveAppSecret")
    public Integer saveAppSecret(@RequestBody PropertyWeChatDTO propertyWeChatDTO) throws Exception {
        return iPropertyWeChatService.saveAppSecret(propertyWeChatDTO);
    }
}
